#include <bits/stdc++.h>

using namespace std;

int T;
struct node
{
    int color;
    int num;
};
vector<node> vec;
int n;
int ans = -1;
int find()
{
    int num = 0;
    for (int i = 1; i <= n; i++)
    {
        //cout << i << " :" << vec[i].color;
        for (int j = i - 1; j >= 1; j--)
        {
            //cout << "  " << j << " :" << vec[j].color << " ";
            if (vec[j].color == vec[i].color &&
                vec[j].num != vec[i].num)
                break;
            if (vec[j].color == vec[i].color &&
                vec[j].num == vec[i].num)
            {
                num += vec[j].num;
                break;
            }
        }
        //cout << endl;
    }
    return num;
}
void dfs(int i)
{
    if (i == n + 1)
    {
        ans = max(ans, find());
        return;
    }
    vec[i].color = 0;
    dfs(i + 1);
    vec[i].color = 1;
    dfs(i + 1);
}

int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);

    cin >> T;

    while (T--)
    {
        ans = -1;
        vec.clear();

        node *n2 = new node;
        n2->color = -1;
        n2->num = 0;
        vec.push_back(*n2);
        delete n2;

        cin >> n;

        for (int i = 1; i <= n; i++)
        {
            int a;
            cin >> a;
            node n;
            n.color = -1;
            n.num = a;
            vec.push_back(n);
        }
        dfs(1);
        cout << ans << endl;
    }

    return 0;
}
